float example
Floats
Instructions:
- Give the section with the class float a 700 pixel width and center it. Hint. The section is a block element, so text-align: center; does not work.
- Add a 3 pixel grey border on the bottom of the header tag.
- Display the menu horizontally across the page.
- Remove the underline from the links and color them white. Color background red.
- Give links a 10 pixel margins, 10px 20px padding and set their display to inline-block.
- Style the hover green.
- The left and right columns are to be exactly 150 pixels wide. Color the background "silver".
- The center column is to be 400 pixels wide and the background is colored #ddd;.
- Using floats, position the three content boxes so that the web page is a 3 column layout.
- Add 20 pixel padding to all columns. Hint. All columns are divs.
Make the float layout responsive.
- When the screen goes below 700 pixels set media queries to true: @media screen and (max-width: 700px) {}
- Display the navigation list items as blocks.
- Set the width of navigation links to 100% and center the text. This works because the links are displayed as inline-blocks.
- Set column width to 100%. This stacks the floats.
- Add 10 pixel padding to the sides of section elements.
Part 2: Display Table
Display Header
Display Table
Display Table
Instructions:
- Keep the width and background color of the columns from above.
- Using the display property, turn these three content boxes into columns similar to the three column layout above.
- Display the container as a table and the three columns as table cells.
- Target the header specific to this section and color the background #ddd.
Make the layout responsive.
- When the screen goes below 600 pixels engage media queries: @media screen and (max-width: 600px)
- Target the columns and their container. Set display to block.
- When that didn't work as expected I had to add some persuasion. !important does the trick.
Right column
Part 3: Grid
Grid Header
Main content
Grid header
Grid Property
- Target the section with the class "gid" and display it as a grid with a 10 pixel grid-gap.
- Make grid horizontal with two grid flex units. Set the first to 1 and the second to 3: grid-template-columns: 1fr 3fr;
- Set the header and footer to span both columns: grid-column: 1 / -1;
- Select all elements inside of the grid and make the background silver, padding at 20 pixels, a 20 pixel margin on either side, and set the border-radius to 5 pixels. Hint, use universal selector to select the children.
- Target class header and set display to flex.
- Target the h1 inside the header and give it auto margins.
- put 1em of padding at the bottom of headings and paragraphs.
Make the grid responsive.
- Set a media query to activate when viewport is less than 500 pixels: @media screen and (max-width: 500px)
- Turn grid into display block.
- For what used to be the grid children, get rid of border radius and add a 5 pixel margin on the border;